package pe.com.drokasa.rest.webservice.conexion;

import pe.com.drokasa.mirror.conexion.MirrorConnection;

/**
 * @author Synopsis S.A
 *
 */
public class ConexionCliente 
{
	/**
	 * IP MIRROR
	 */
	private static final String IP_MIRROR = "192.168.236.30";
	
	/**
	 * PUERTO MIRROR
	 */
	private static final int PUERTO_MIRROR = 2000;
	
	/**
	 * NODO EN MIRROR
	 */
	private static final String NODO_MIRROR = "INTDEV";
	
	/**
	 * APPL EN MIRROR
	 */
	private static final String APPL_MIRROR = "DKSFA-OFF";
	
	/**
	 * TIMEOUT
	 */
	private static final int LIMITE_TIME_OUT = 5000;
	
	public static String ejecutarOperacion(String trama)
	{
		String response = "";
		
		try 
		{
			MirrorConnection con = new MirrorConnection();
			con.setNode(IP_MIRROR);
			con.setPort(PUERTO_MIRROR);
			con.setTimeout(LIMITE_TIME_OUT);
			con.setNodeDestination(NODO_MIRROR);
			con.setHandle(APPL_MIRROR);
			con.setUsername("PC");
			con.setMessage(trama);
			con.open();
			con.send();
			response = con.getResponse();
			con.close();
		} 
		catch (Exception e) 
		{
			System.out.println("Error: " + e);
		}
		
		return response;
	}
}